package com.systop.asset.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.systop.asset.entity.Repair;
import com.systop.asset.entity.RestResponse;
import com.systop.asset.entity.vo.AssetFixVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.systop.asset.service.IRepairService;


/**
 * 资产维修记录Controller
 * 
 * @author cc
 * @date 2025-07-04
 */
@RestController
@RequestMapping("/system/repair")
public class RepairController
{
    @Autowired
    private IRepairService repairService;

    /**
     * 查询资产维修记录列表
     */
    @GetMapping("/list")
    public RestResponse list(Repair repair)
    {
        List<Repair> list = repairService.selectRepairList(repair);
        return RestResponse.success(list);
    }

    /**
     * 获取资产维修记录详细信息
     */
    @GetMapping(value = "/{id}")
    public RestResponse getInfo(@PathVariable("id") Long id)
    {
        return RestResponse.success(repairService.selectRepairById(id));
    }

    /**
     * 新增资产维修记录
     */

    @PostMapping
    public RestResponse add(@RequestBody Repair repair)
    {
        return RestResponse.success(repairService.insertRepair(repair));
    }

    /**
     * 修改资产维修记录
     */
    @PutMapping
    public RestResponse edit(@RequestBody Repair repair)
    {
        return RestResponse.success(repairService.updateRepair(repair));
    }

    /**
     * 删除资产维修记录
     */
	@DeleteMapping("/{ids}")
    public RestResponse remove(@PathVariable Long[] ids)
    {
        return RestResponse.success(repairService.deleteRepairByIds(ids));
    }

    /**
     * 查询资产维修记录列表
     */
    @GetMapping("/detail")
    public RestResponse detail(String id)
    {
        AssetFixVO assetFix = repairService.selectDetail(id);
        return RestResponse.success(assetFix);
    }
}
